#ifndef __HEAP_H_
#define __HEAP_H_

#include <ds/semaphore.h>
#include <type.h>

#define MAGICNUMBER 0xABABBABA

typedef struct {
    void* start;
    void* end;
    sem_t sem;
} heap_t;

typedef struct {
    u32 magic;
    u8 used;
    u32 size;
} header_t;

typedef struct {
    u32 magic;
    header_t* header;
} footer_t;

void heap_init(heap_t* heap);

void heap_expand(heap_t* heap, u32 size);

void* alloc(heap_t* curr_heap, u32 size);

void free(heap_t* curr_heap, void* ptr);

#endif